#!/bin/bash

echo "AI 生辰八字算命系统启动脚本"
echo "================================"

echo "检查 Python 环境..."
python3 --version
if [ $? -ne 0 ]; then
    echo "错误：未找到 Python，请先安装 Python 3.8+"
    exit 1
fi

echo ""
echo "安装依赖包..."
pip3 install -r requirements.txt
if [ $? -ne 0 ]; then
    echo "错误：依赖包安装失败"
    exit 1
fi

echo ""
echo "检查环境配置..."
if [ ! -f .env ]; then
    echo "警告：未找到 .env 文件"
    echo "请参考 env_example.txt 创建 .env 文件"
    echo "至少需要配置 OPENAI_API_KEY"
    echo ""
fi

echo ""
echo "启动应用..."
echo "访问地址: http://localhost:8000"
echo "API 文档: http://localhost:8000/docs"
echo ""
echo "按 Ctrl+C 停止服务"
echo ""

python3 run.py
